package com.mission.schedule.CommonDialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.StyleRes;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.mission.schedule.R;
import com.mission.schedule.adapter.FriendsSelectAdapter;
import com.mission.schedule.annotation.ViewResId;
import com.mission.schedule.applcation.App;
import com.mission.schedule.bean.FriendsBean;
import com.mission.schedule.bean.MySchBean;
import com.mission.schedule.constants.ShareFile;
import com.mission.schedule.utils.SharedPrefUtil;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 日程好友转发对话框
 * Created by liwei on 2017/4/18.
 */

public class CalenderFirendDialog extends Dialog {
    @ViewResId(id = R.id.friends_lv)
    private ListView friends_lv;

    CallBack callBack;


    SharedPrefUtil sharedPrefUtil = null;
    WindowManager windowManager;

    Context context;
    String userId;
    String path;
    FriendsSelectAdapter adapter = null;
    List<FriendsBean> beansList = new ArrayList<FriendsBean>();
    FriendsBean friendsBean = null;
    MySchBean mySchBean = null;

    List<Map<String, String>> addList = new ArrayList<Map<String, String>>();
    List<Map<String, String>> updateList = new ArrayList<Map<String, String>>();
    List<Map<String, String>> deleteList = new ArrayList<Map<String, String>>();
    String json;

    App app;
    String myName;
    int ID;


    public CalenderFirendDialog(@NonNull final Context context, @StyleRes int themeResId, WindowManager windowManager,MySchBean bean) {
        super(context, themeResId);
        this.context = context;
        this.windowManager = windowManager;

        setCanceledOnTouchOutside(true);

        View view = LayoutInflater.from(context).inflate(R.layout.dialog_zhuanfafirend, null);
        setContentView(view);

        this.mySchBean = bean;

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Window window = getWindow();
        window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN | WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
        WindowManager.LayoutParams params = window.getAttributes();
        window.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
        params.width = windowManager.getDefaultDisplay().getWidth();
        params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        window.setAttributes(params);


        sharedPrefUtil = new SharedPrefUtil(context, ShareFile.USERFILE);
        app = App.getDBcApplication();
        userId = sharedPrefUtil.getString(context, ShareFile.USERFILE,
                ShareFile.USERID, "");
        myName = sharedPrefUtil.getString(context, ShareFile.USERFILE,
                ShareFile.USERNAME, "");
    }

    public interface CallBack {
        void reminderEditTime(double number, int type);
    }

    public CallBack getCallBack() {
        return callBack;
    }

    public void setCallBack(CallBack callBack) {
        this.callBack = callBack;
    }
}
